<template>
	<view>
		<view class="bj1">
			<span class="sj">每日签到</span>
			{{time}}
		</view>
		<view style="margin-top: -85px;">
			<uni-calendar value="time" :showMonth="false" @change="initsignin"></uni-calendar>
		</view>
		<u-button v-if="qd=='' || qd=='今日未签到'" @click="setsignin" type="primary" color="#2FCEDE" style="width: 100px;height: 100px;border-radius: 50%;margin-top: 20px;"><span style="font-size: 16px;"><b>点击签到</b></span></u-button>
		<u-button v-if="qd=='未签到过期'" type="primary" color="#2FCEDE" style="width: 100px;height: 100px;border-radius: 50%;margin-top: 20px;" disabled><span style="font-size: 16px;"><b>{{qd}}</b></span></u-button>
		<u-button v-if="qd=='已签到'" type="primary" color="#2FCEDE" style="width: 100px;height: 100px;border-radius: 50%;margin-top: 20px;"disabled><span style="font-size: 16px;"><b>已签到{{count}}天</b></span></u-button>
		<u-button v-if="qd=='未到时间'" type="primary" color="#2FCEDE" style="width: 100px;height: 100px;border-radius: 50%;margin-top: 20px;"disabled><span style="font-size: 16px;"><b>{{qd}}</b></span></u-button>
		<view class="db"></view>
		<uni-popup ref="popup2" :mask-click="false">
			<button @click="close2">取消</button>
		</uni-popup>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userid:'',
				time:'',
				qd:'',
				count:0,
			}
		},
		onLoad() {
			this.initsignin()
		},
		methods: {
			close2() {
				// this.$refs.popup2.close()
			},
			setsignin(){
				uni.request({
					url:'http://localhost:9525/xkuser/ljp/setsignin',
					method: 'GET',
				   data: {
					   userid: this.userid,
					   // time:time.fulldate,
				   },
				   dataType:'json',
				   success: (res) => {
					   var mar=res.data.message
					   this.qd=mar
					   this.count=res.data.data.count
					   // this.$refs.popup2.open('bottom')
					   
						
							
					},
				})	
			},
			change(time){
				console.log(time)
			},
			initsignin(time){
				uni.getStorage({
					key:'userid',
					success: res=>{
						this.userid=res.data
					}
				})
				// console.log(new Data())
				var times=''
				if(time==null){
					times=null
				}else{
					times=time.fulldate
				}
				uni.request({
					url:'http://localhost:9525/xkuser/ljp/initsignin',
					method: 'GET',
				   data: {
					   userid: this.userid,
					   time:times,
				   },
				   dataType:'json',
				   success: (res) => {
					   var mar=res.data.message
					   this.qd=mar
					   if(mar=="已签到"){
						   this.count=res.data.data.count
					   }
					   console.log(res)
						
							
					},
				})	
			}
		}
	}
</script>

<style>
	.db{
		width: 100%;
		height: 187px;
		margin-top: -85px;
		background-image: url(../../static/indeimg/qiandao.png);
	}
	.sj{
		font-family: '微软雅黑 Bold', '微软雅黑 Regular', '微软雅黑';
		    font-weight: 700;
		    font-size: 20px;
		    color: #FFFFFF;
		    margin-left: 15px;
			position: absolute;
			top: 20px;
	}
	.bj1{
			width:100%;
			height:468rpx;
			background-image: url(../../static/indeimg/xia.png);
			
		}
</style>
